//
//  CedarTools.h
//  CedarSuperCloud
//
//  Created by lshenrong on 2017/11/24.
//  Copyright © 2017年 cedarhd. All rights reserved.
//

#import <Foundation/Foundation.h>
 #import <CommonCrypto/CommonCryptor.h>
@interface CedarTools : NSObject

#pragma mark - string
////////////////////////   字符串    ////////////////////////
/**
 截取字符串 从前找
 */
+ (NSString *)substring:(NSString *)str sign:(NSString *)signStr;
+ (NSString *)replacingMiddleStarByPhone:(NSString *)phone;
+ (NSString *)randomSixString;
+ (NSString *)dictToJsonStr:(NSDictionary *)dict;
+ (NSString *)splitFomateJsonWithDictionary:(NSDictionary *)dict;
+ (NSString *)replacingMiddleStarByName:(NSString *)name;

+ (NSString *)replaceUnicode:(NSString *)unicodeStr;

/**
 找字符串, 12.0% ->12 ; 13%->13
 */
+ (NSString *)subStringWithPercent:(NSString *)str sign:(NSString *)signStr;
/**
 身份证号码判断
 */
+ (BOOL)isValidateIdentityCardNo:(NSString *)identityString;

+ (BOOL)validateIDCardNumber:(NSString *)value;


/**
 找字符串，从开始 针对利率 如 12.30%~15.60%  取 12  
 */
+ (NSRange)findStringFromBegin:(NSString *)string key:(NSString *)key;
/**
 找字符串，从后找 针对利率 如 12.30%-15.60%  取 15
 */
+ (NSRange )findStringFromBackwards:(NSString *)string key:(NSString *)key;

/**
 从字符串尾部开始查找
 */
+ (NSRange)findStringBackwards:(NSString *)str  start:(NSString *)start end:(NSString *)end;
/**
 截取字符串后4位
 */
+ (NSString *)lastFourString:(NSString *)str;

+ (NSString *)substringTime:(NSString *)str;
+ (NSString *)substringTimeToMinute:(NSString *)str;
+ (NSString *)substringTimeSecond:(NSString *)str;
+ (NSString *)substringTimeReplacePoint:(NSString *)str;
//2017:08:12 12:25:30 ->5月2日 12:25
+ (NSString *)praseTimeForMonthDayHourMintue:(NSString *)str;

+ (NSString *)praseTimeForDayHourMintue:(NSString *)str;

+ (NSRange)findString:(NSString *)str  start:(NSString *)start end:(NSString *)end;

/**
 中间替换为*
 */
+ (NSString *)replaceMiddleStarExceptLastFourString:(NSString *)str;

/**
  身份证  中间替换为*
 */

+ (NSString *)idCardReplaceMiddleStarExceptLastFourString:(NSString *)str;

#pragma mark - tools

+ (BOOL)isPhoneNumber:(NSString *)phone;
+ (BOOL)isVaildPassword:(NSString *)password;

+ (BOOL)isVaildIdentityNo:(NSString *)identityString;
+ (NSString *)characterURL:(NSString *)sourceUrl;

#pragma mark - encypt
/**
 加解密
 */
+ (NSString*)encyptAES128PKCS5:(NSString*)plainText withKey:(NSString*)key;
+ (NSString*)decryptAES128PKCS5:(NSString*)plainText withKey:(NSString*)key;



////////////////////////   货币    ////////////////////////
#pragma mark -  money

/**
 千分位格式
 */
+ (NSString *)thousandFormat:(NSString *)text;

/**
 不显示小数位(小于1格式化2位小数点，只舍不入)
 */
+ (NSString *)thousandFormatNoDecimalPoint:(NSString *)text;

/**
 相加
 */
+ (NSString *)number:(NSString *)number1 byAdd:(NSString *)number2;
+ (NSString *)number:(NSString *)number1 byReduce:(NSString *)number2;
+ (NSString *)number:(NSString *)number1 byMultiplying:(NSString *)number2;
+ (NSString *)number:(NSString *)number1 byDividing:(NSString *)number2;

//相减，相乘，返回数值
+ (NSDecimalNumber *)number1:(NSString *)number1 byReduceNumber2:(NSString *)number2;
+ (NSDecimalNumber *)number1:(NSString *)number1 byMultiplyingNumber2:(NSString *)number2;

/**
 比较 number1 与number2的 大小
 NSOrderedSame 相等
 NSOrderedAscending number1 小于nubmer2
 NSOrderedDescending number1 大于nubmer2
 */
+ (NSComparisonResult)number:(NSString *)number1 compareNumber:(NSString *)number2;



/**
 转换价格，万元或元 ,没有小数点
 */
//+ (NSString *)converToPriceString:(NSString *)money;

/**
 输入的金额是否满足最低 递增 规则
 */
+ (BOOL)isAllowConditionMoney:(NSString *)money minAmount:(NSString *)min increaseAmount:(NSString *)increase;
+ (BOOL)judgeDivisibleWithFirstNumber:(CGFloat)firstNumber andSecondNumber:(CGFloat)secondNumber;


/**
 格式化两位小数
 */
+ (NSString *)moneyFormatForTwoDecimalNumString:(NSString *)text;


/**
 截取价格（只舍不入），position 保留小数点几位 ,（如果没有则不显示小数点后）
 */
+ (NSString *)moneyNotRounding:(NSString *)money  afterPoint:(NSInteger)position;


/**
 格式化2位小数，没有补0 不四5入
 */
+ (NSString *)moneyFormateAfterTwoPoint:(NSString *)money;


/**
 格式化为无小数点  23.09 -> 23
 */
+ (NSString *)thousandFormatWithNoDecimalPoint:(NSString *)text;


/**
 转化为万 无单位 10000->1  100->0.0100
 */
+ (NSString *)thousandFormatForTenThousandNoDecimalPoint:(NSString *)text;

/**
 格式化万 带有单位 10000 -> 1万
 */
+ (NSString *)thousandFormatForTenThousandWithUnitNoDecimalPoint:(NSString *)text;


/**
 格式化移除小数点后多余的零
 */
+ (NSString *)moneyFormateRemoveDecimalPointZero:(NSString *)money;


/**
 空字符转换为 0
 */
+ (NSString *)emptyStringToZero:(NSString *)str;

#pragma mark - image compress

- (UIImage *)compressOriginalImage:(UIImage *)image toMaxDataSizeKBytes:(CGFloat)size;

@end
